package com.nursing.think.view;

import android.content.Context;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.nursing.think.R;

/**
 * Created by Android Studio.
 *
 * @author: liyunsheng
 * Date: 2021-11-24
 * Time: 10:06
 */

public class CustomToast extends Toast {

    TextView textView;
    /**
     * Construct an empty Toast object.  You must call {@link #setView} before you
     * can call {@link #show}.
     *
     * @param context The context to use.  Usually your {@link Application}
     *                or {@link Activity} object.
     */
    public CustomToast(Context context) {
        super(context);
        init(context);
    }

    private void init(Context context) {
        View view = View.inflate(context, R.layout.layout_toast,null);
        textView = (TextView) view.findViewById(R.id.content);
        setView(view);
    }

    @Override
    public void setText(CharSequence sequence){
        textView.setText(sequence);
    }

    @Override
    public void setText(int resId) {
        textView.setText(resId);
    }
}
